
import { type IComponentConfig, ChannelEnum } from '../../types'
import { placements } from '../util'

const props: IComponentConfig[] = [{
  type: 'dataSource',
  component: 'DataSource',
  label: '数据源',
  model: 'dataSource',
  defaultValue: {
    type: 'static',
    value: [{
      option_key: 'shanghai',
      option_desc: '上海'
    }]
  }
}, {
  type: 'switch',
  component: 'eSwitch',
  label: '是否支持多选',
  model: 'multiple',
  defaultValue: false
}, {
  type: 'switch',
  component: 'eSwitch',
  label: '是否禁用',
  model: 'disabled',
  defaultValue: false
}, {
  type: 'switch',
  component: 'eSwitch',
  label: '是否可以清空选项，只在单选时有效',
  model: 'clearable',
  defaultValue: false
}, {
  type: 'switch',
  component: 'eSwitch',
  label: '是否支持搜索',
  model: 'filterable',
  defaultValue: false
}, {
  type: 'switch',
  component: 'eSwitch',
  label: '在搜索时，是否只按照label进行搜索',
  model: 'filterByLabel',
  defaultValue: false
}, {
  type: 'switch',
  component: 'eSwitch',
  label: '在返回选项时，是否将label和value一并返回',
  model: 'labelnValue',
  defaultValue: false
}, {
  type: 'switch',
  component: 'eSwitch',
  label: '是否将弹层放置于body内',
  model: 'transfer',
  defaultValue: false
}, {
  type: 'select',
  component: 'eSelect',
  label: '弹窗的展开方向',
  model: 'placement',
  defaultValue: 'bottom-start',
  props: {
    dataSource: {
      type: 'static',
      value: placements
    },
    transfer: true
  }
}, {
  type: 'input',
  component: 'eInput',
  label: '占位文本',
  model: 'placeholder',
  defaultValue: '请选择'
}]

const events: IComponentConfig[] = [{
  type: 'codeEditor',
  component: 'CodeEditor',
  label: 'onChange',
  model: 'on-change',
  defaultValue: `function fn() {
  
}`
}]

const slots: IComponentConfig[] = []

const drag = {
  compName: 'eSelect',
  label: '下拉框',
  classify: {
    label: '基础',
    value: 'basic'
  },
  channel: ChannelEnum.PC,
  group: {
    label: '表单',
    value: 'form'
  },
  icon: 'icon-sort'
}

export default {
  drag,
  props,
  events,
  slots
}
